<template>
	<view class="onlinetime">
		<view class="onlinetime_box">
			<view class="onlinetime_box_tab">
				<view class="onlinetime_box_tab_a" @click="today(1)" :class="ID==1 ? 'items':''">
					<text class="text1">今天</text>
					<text class="text2">{{shijian1}}</text>
				</view>
				<view class="onlinetime_box_tab_a" @click="today2(2)" :class="ID==2 ? 'items':''">
					<text class="text1">明天</text>
					<text class="text2">{{shijian2}}</text>
				</view>
				<view class="onlinetime_box_tab_a" @click="today3(3)" :class="ID==3 ? 'items':''">
					<text class="text1">后天</text>
					<text class="text2">{{shijian3}}</text>
				</view>
			</view>
			<view class="onlinetime_box_main" v-if="ID==1">
				<u-button class="btn" @click="btn(item,index)" :disabled="item.num==1"
					:style="item.num===1?'border: 2rpx solid #cccccc;' : ''"
					:class="{'active':selectedTwo[index].value == item.value}" v-for="(item,index) in lists"
					:key="index">{{item.value}}</u-button>
				<view>{{dateFormat(date)}}</view>
			</view>
			<view>
				<view class="onlinetime_box_main" v-if="ID==2">
					<u-button class="btn" @click="btn2(item,index)"
						:class="{'active2':selectedTwo2[index].valuea == item.valuea}" v-for="(item,index) in lists1"
						:key="index">{{item.valuea}}</u-button>
					<view>{{dateFormat(date)}}</view>
				</view>
			</view>

			<view class="onlinetime_box_main" v-if="ID==3">
				<u-button class="btn" @click="btn3(item,index)"
					:class="{'active':selectedTwo3[index].valueb == item.valueb}" v-for="(item,index) in lists2"
					:key="index">{{item.valueb}}</u-button>
				<view>{{dateFormat(date)}}</view>

			</view>

			<view class="queding" @click="confirms" v-if="lineShow==false && ID!==2 && ID!==3">
				确定上线
			</view>
			<view class="lixian" @click="offline" v-if="lineShow && ID!==2 && ID!==3">
				确定离线
			</view>
			<view class="queding" @click="confirms2" v-if="ID==2">
				保存可预约时间
			</view>
			<view class="queding" @click="confirms3" v-if="ID==3">
				保存可预约时间
			</view>
		</view>
		<!-- <button >{{shijian}}{{shijian1}}{{shijian2}}{{shijian3}}</button> -->
	</view>
</template>

<script>
	let starts = -1
	let ends = -1
	let starts1 = -1
	let ends1 = -1
	let starts2 = -1
	let ends2 = -1
	import homeServices from '../../service/homeService'
	export default {
		data() {
			return {
				lineShow: '',
				date: new Date().toISOString(), //现在时间
				ID: 1,
				list: [{
						id: 1,
						name: '今天',
						name1: ''
					},
					{
						id: 2,
						name: '明天',
						name1: '',
					},
					{
						id: 3,
						name: '后天',
						name1: '',
					},
				],
				lists: [{
						num: 0,
						value: '00:00',
					},
					{
						num: 0,
						value: '00:30',
					},
					{
						num: 0,
						value: '01:00',
					},
					{
						num: 0,
						value: '01:30',
					},
					{
						num: 0,
						value: '02:00',
					},
					{
						num: 0,
						value: '02:30',
					},
					{
						num: 0,
						value: '03:00',
					},
					{
						num: 0,
						value: '03:30',
					},
					{
						num: 0,
						value: '04:00',
					},
					{
						num: 0,
						value: '04:30',
					},
					{
						num: 0,
						value: '05:00',
					},
					{
						num: 0,
						value: '05:30',
					},
					{
						num: 0,
						value: '06:00',
					},
					{
						num: 0,
						value: '06:30',
					},
					{
						num: 0,
						value: '07:00',
					},
					{
						num: 0,
						value: '07:30',
					},
					{
						num: 0,
						value: '08:00',
					},
					{
						num: 0,
						value: '08:30',
					},
					{
						num: 0,
						value: '09:00',
					},
					{
						num: 0,
						value: '09:30',
					},
					{
						num: 0,
						value: '10:00',
					},
					{
						num: 0,
						value: '10:30',
					},
					{
						num: 0,
						value: '11:00',
					},
					{
						num: 0,
						value: '11:30',
					},
					{
						num: 0,
						value: '12:00',
					},
					{
						num: 0,
						value: '12:30',
					},
					{
						num: 0,
						value: '13:00',
					},
					{
						num: 0,
						value: '13:30',
					},
					{
						num: 0,
						value: '14:00',
					},
					{
						num: 0,
						value: '14:30',
					},
					{
						num: 0,
						value: '15:00',
					},
					{
						num: 0,
						value: '15:30',
					},
					{
						num: 0,
						value: '16:00',
					},
					{
						num: 0,
						value: '16:30',
					},
					{
						num: 0,
						value: '17:00',
					},
					{
						num: 0,
						value: '17:30',
					},
					{
						num: 0,
						value: '18:00',
					},
					{
						num: 0,
						value: '18:30',
					},
					{
						num: 0,
						value: '19:00',
					},
					{
						num: 0,
						value: '19:30',
					},
					{
						num: 0,
						value: '20:00',
					},
					{
						num: 0,
						value: '20:30',
					},
					{
						num: 0,
						value: '21:00',
					},
					{
						num: 0,
						value: '21:30',
					},
					{
						num: 0,
						value: '22:00',
					},
					{
						num: 0,
						value: '22:30',
					},
					{
						num: 0,
						value: '23:00',
					},
					{
						num: 0,
						value: '23:30',
					},
					// {
					// 	num: 0,
					// 	value: '24:00',
					// }


				],
				lists1: [{
						num: 0,
						valuea: '00:00',
					},
					{
						num: 0,
						valuea: '00:30',
					},
					{
						num: 0,
						valuea: '01:00',
					},
					{
						num: 0,
						valuea: '01:30',
					},
					{
						num: 0,
						valuea: '02:00',
					},
					{
						num: 0,
						valuea: '02:30',
					},
					{
						num: 0,
						valuea: '03:00',
					},
					{
						num: 0,
						valuea: '03:30',
					},
					{
						num: 0,
						valuea: '04:00',
					},
					{
						num: 0,
						valuea: '04:30',
					},
					{
						num: 0,
						valuea: '05:00',
					},
					{
						num: 0,
						valuea: '05:30',
					},
					{
						num: 0,
						valuea: '06:00',
					},
					{
						num: 0,
						valuea: '06:30',
					},
					{
						num: 0,
						valuea: '07:00',
					},
					{
						num: 0,
						valuea: '07:30',
					},
					{
						num: 0,
						valuea: '08:00',
					},
					{
						num: 0,
						valuea: '08:30',
					},
					{
						num: 0,
						valuea: '09:00',
					},
					{
						num: 0,
						valuea: '09:30',
					},
					{
						num: 0,
						valuea: '10:00',
					},
					{
						num: 0,
						valuea: '10:30',
					},
					{
						num: 0,
						valuea: '11:00',
					},
					{
						num: 0,
						valuea: '11:30',
					},
					{
						num: 0,
						valuea: '12:00',
					},
					{
						num: 0,
						valuea: '12:30',
					},
					{
						num: 0,
						valuea: '13:00',
					},
					{
						num: 0,
						valuea: '13:30',
					},
					{
						num: 0,
						valuea: '14:00',
					},
					{
						num: 0,
						valuea: '14:30',
					},
					{
						num: 0,
						valuea: '15:00',
					},
					{
						num: 0,
						valuea: '15:30',
					},
					{
						num: 0,
						valuea: '16:00',
					},
					{
						num: 0,
						valuea: '16:30',
					},
					{
						num: 0,
						valuea: '17:00',
					},
					{
						num: 0,
						valuea: '17:30',
					},
					{
						num: 0,
						valuea: '18:00',
					},
					{
						num: 0,
						valuea: '18:30',
					},
					{
						num: 0,
						valuea: '19:00',
					},
					{
						num: 0,
						valuea: '19:30',
					},
					{
						num: 0,
						valuea: '20:00',
					},
					{
						num: 0,
						valuea: '20:30',
					},
					{
						num: 0,
						valuea: '21:00',
					},
					{
						num: 0,
						valuea: '21:30',
					},
					{
						num: 0,
						valuea: '22:00',
					},
					{
						num: 0,
						valuea: '22:30',
					},
					{
						num: 0,
						valuea: '23:00',
					},
					{
						num: 0,
						valuea: '23:30',
					},
					// {
					// 	num: 0,
					// 	valuea: '24:00',
					// }


				],

				lists2: [{
						num: 0,
						valueb: '00:00',
					},
					{
						num: 0,
						valueb: '00:30',
					},
					{
						num: 0,
						valueb: '01:00',
					},
					{
						num: 0,
						valueb: '01:30',
					},
					{
						num: 0,
						valueb: '02:00',
					},
					{
						num: 0,
						valueb: '02:30',
					},
					{
						num: 0,
						valueb: '03:00',
					},
					{
						num: 0,
						valueb: '03:30',
					},
					{
						num: 0,
						valueb: '04:00',
					},
					{
						num: 0,
						valueb: '04:30',
					},
					{
						num: 0,
						valueb: '05:00',
					},
					{
						num: 0,
						valueb: '05:30',
					},
					{
						num: 0,
						valueb: '06:00',
					},
					{
						num: 0,
						valueb: '06:30',
					},
					{
						num: 0,
						valueb: '07:00',
					},
					{
						num: 0,
						valueb: '07:30',
					},
					{
						num: 0,
						valueb: '08:00',
					},
					{
						num: 0,
						valueb: '08:30',
					},
					{
						num: 0,
						valueb: '09:00',
					},
					{
						num: 0,
						valueb: '09:30',
					},
					{
						num: 0,
						valueb: '10:00',
					},
					{
						num: 0,
						valueb: '10:30',
					},
					{
						num: 0,
						valueb: '11:00',
					},
					{
						num: 0,
						valueb: '11:30',
					},
					{
						num: 0,
						valueb: '12:00',
					},
					{
						num: 0,
						valueb: '12:30',
					},
					{
						num: 0,
						valueb: '13:00',
					},
					{
						num: 0,
						valueb: '13:30',
					},
					{
						num: 0,
						valueb: '14:00',
					},
					{
						num: 0,
						valueb: '14:30',
					},
					{
						num: 0,
						valueb: '15:00',
					},
					{
						num: 0,
						valueb: '15:30',
					},
					{
						num: 0,
						valueb: '16:00',
					},
					{
						num: 0,
						valueb: '16:30',
					},
					{
						num: 0,
						valueb: '17:00',
					},
					{
						num: 0,
						valueb: '17:30',
					},
					{
						num: 0,
						valueb: '18:00',
					},
					{
						num: 0,
						valueb: '18:30',
					},
					{
						num: 0,
						valueb: '19:00',
					},
					{
						num: 0,
						valueb: '19:30',
					},
					{
						num: 0,
						valueb: '20:00',
					},
					{
						num: 0,
						valueb: '20:30',
					},
					{
						num: 0,
						valueb: '21:00',
					},
					{
						num: 0,
						valueb: '21:30',
					},
					{
						num: 0,
						valueb: '22:00',
					},
					{
						num: 0,
						valueb: '22:30',
					},
					{
						num: 0,
						valueb: '23:00',
					},
					{
						num: 0,
						valueb: '23:30',
					},
					// {
					// 	num: 0,
					// 	valueb: '24:00',
					// }


				],


				shijian: '',
				shijian1: '',
				shijian2: '',
				shijian3: '',
				shijian4: '',
				shijian5: '',
				shijian6: '',
				xianzai: '',
				xianzai1: '',
				mingtai1: '',
				mingtai2: '',
				houtian1: '',
				houtian2: '',
				a: 0,
				longitude: '',
				latitude: '',
				value1: '',
				value2: '',
				value3: '',
				value4: '',
				value5: '',
				value6: '',
				selected: [],
				selectedTwo: [],
				selected2: [],
				selectedTwo2: [],
				selected3: [], 
				selectedTwo3: [],
				sj: '',
				sj1: '',
				mt1: '',
				mt2: '',
				Number: true,
				obj: false
			}

		},
		methods: {
			async today(id){
				this.ID=id
				let params = {
					date:this.shijian4
				}
				let res = await homeServices.today(params)
				if(res.status==200){
					let expectStartTime=res.data[0].expectStartTime.substring(11,16)
					let expectEndTime=res.data[0].expectEndTime.substring(11,16)
					let fisrtindex=	this.lists.findIndex(res=>{
						console.log(res)
						return res.value==expectStartTime
					})
					let enderindex=	this.lists.findIndex(res=>{
						return res.value==expectEndTime
					})
					
					this.selected=this.lists.slice(fisrtindex,enderindex)
					
					console.log(this.selectedTwo);
					
					
						let start = fisrtindex-1
						let end = enderindex
						this.lists.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo[index], 'value', it.value)
							}
						})
					
						starts = start
						ends = end
					
					console.log(fisrtindex,enderindex)
					console.log(this.selectedTwo)
				}
				console.log(res,'pppppppppppp')
				// this.btn()
			},
		 async	today2(id){
				this.ID=id
				let params = {
					date:this.shijian5
				}
				let res = await homeServices.today(params)
				console.log(res)
				if(res.status==200){
					let expectStartTime=res.data[0].expectStartTime.substring(11,16)
					let expectEndTime=res.data[0].expectEndTime.substring(11,16)
					console.log(expectStartTime,expectEndTime)
					let fisrtindex=	this.lists1.findIndex(res=>{
						console.log(res)
						return res.valuea==expectStartTime
					})
					let enderindex=	this.lists1.findIndex(res=>{
						return res.valuea==expectEndTime
					})
					
					this.selected2=this.lists1.slice(fisrtindex,enderindex)
					
					console.log(this.selectedTwo);
					
					
						let start = fisrtindex-1
						let end = enderindex
						this.lists1.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo2[index], 'valuea', it.valuea)
							}
						})
					
						starts1 = start
						ends1 = end
					
					
					
					
							// this.selectedTwo=this.lists.slice(fisrtindex,enderindex)
					
					
					
					console.log(fisrtindex,enderindex)
					console.log(this.selectedTwo)
				}
			},
		 async	today3(id){ 
				this.ID=id
				let params = {
					date:this.shijian6
				}
				let res = await homeServices.today(params)
				console.log(res)
				if(res.status==200){
					let expectStartTime=res.data[0].expectStartTime.substring(11,16)
					let expectEndTime=res.data[0].expectEndTime.substring(11,16)
					console.log(expectStartTime,expectEndTime)
					let fisrtindex=	this.lists2.findIndex(res=>{
						console.log(res)
						return res.valueb==expectStartTime
					})
					let enderindex=	this.lists2.findIndex(res=>{
						return res.valueb==expectEndTime
					})
					
					this.selected3=this.lists2.slice(fisrtindex,enderindex)
					
					console.log(this.selectedTwo);
					
					
						let start = fisrtindex-1
						let end = enderindex
						this.lists2.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo3[index], 'valueb', it.valueb)
							}
						})
					
						starts1 = start
						ends1 = end
					
					
					
					
							// this.selectedTwo=this.lists.slice(fisrtindex,enderindex)
					
					
					
					console.log(fisrtindex,enderindex)
					console.log(this.selectedTwo)
				}
			},
			async homeluobo() {
				let params = {}
				let res = await homeServices.homeluobo(params)
				this.lineShow = res.data.isOnline
				console.log(this.lineShow);
			},
			getCurrentTime() {
				var time = new Date()
				// var tempTime= [];
				var year = time.getFullYear()+'-';
				var yM = (this.checkTime(time.getMonth() + 1)) + '-'
				var today = time.getDate()
				var moni1 = time.setDate(today + 1);
				var yM2 = (this.checkTime(new Date(moni1).getMonth() + 1)) + '-'

				var time1 = new Date()
				var today2 = time1.getDate()
				var moni2 = time1.setDate(today2 + 2);
				var yM3 = (this.checkTime(new Date(moni2).getMonth() + 1)) + '-'
				this.shijian1 =yM + this.checkTime(today)
				this.shijian2 = yM2 + this.checkTime(new Date(moni1).getDate())
				this.shijian3 = yM3 + this.checkTime(new Date(moni2).getDate())
				
				this.shijian4 =year + yM + this.checkTime(today)
				this.shijian5 =year +  yM2 + this.checkTime(new Date(moni1).getDate())
				this.shijian6 =year +  yM3 + this.checkTime(new Date(moni2).getDate())
				console.log(this.shijian1)
				// tempTime.splice(0,0,temp1)
				// tempTime.splice(1,0,temp2)
				// tempTime.splice(2,0,temp3)
				// this.visitorTime = tempTime;

				var tempNum = [];
				var yNum = time.getFullYear() + '-' + (this.checkTime(time.getMonth() + 1)) + '-';
				var yNum1 = new Date(moni1).getFullYear() + '-' + (this.checkTime(new Date(moni1).getMonth() + 1)) + '-';
				var yNum2 = new Date(moni2).getFullYear() + '-' + (this.checkTime(new Date(moni2).getMonth() + 1)) + '-';
				var num1 = yNum + this.checkTime(today)
				var num2 = yNum1 + this.checkTime(new Date(moni1).getDate())
				var num3 = yNum2 + this.checkTime(new Date(moni2).getDate())
				console.log(yNum)
				// this.visitorTimeNum = tempNum;

			},
			checkTime(i) {
				if (i < 10) return "0" + i;
				return i;
			},

			dateFormat(time) {
				let date = new Date(time);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let today = date.getDate();
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let day1 = date.getDate() + 1 < 10 ? "0" + (date.getDate() + 1) : date.getDate() + 1;
				let day2 = date.getDate() + 2 < 10 ? "0" + (date.getDate() + 2) : date.getDate() + 2;
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				// return  year + "年" + month + "月" + day + "日" + hours + ":" + minutes + ":" + seconds;
				// 今天
				this.xianzai = year + "-" + month + "-" + day + " " + this.value1 + ":" + '00';
				this.xianzai1 = year + "-" + month + "-" + day + " " + this.value2 + ":" + '00';
				console.log(this.xianzai, this.xianzai1, "2222222222")
				// 明天
				let mingtai1 = year + "-" + month + "-" + day1 + " " + this.value3 + ":" + '00';
				let mingtai2 = year + "-" + month + "-" + day1 + " " + this.value4 + ":" + '00';
				console.log(mingtai1, mingtai2, "111111111111")
				// 后天
				let houtian1 = year + "-" + month + "-" + day2 + " " + this.value5 + ":" + '00';
				let houtian2 = year + "-" + month + "-" + day2 + " " + this.value6 + ":" + '00';

				this.sj = this.xianzai
				this.sj1 = this.xianzai1
				this.mt1 = mingtai1
				this.mt2 = mingtai2
				this.houtian1 = houtian1
				this.houtian2 = houtian2
				// console.log(this.mt1,this.mt2,"111111111111")
				// console.log(this.sj1)
				this.shijian = hours + ":" + minutes
				this.lists.forEach(item => {
					if (this.shijian > item.value) {
						item.num = 1
					}

				});
				console.log(this.shijian, 'pppppppppppppppppp')

				// return year + "-" + month + "-" + day;
			},
			btn(item, index) {
				let value1 = "";
				let value2 = "";
				console.log(this.selected.length);
				if (index >= starts && index <= ends && this.selected.length >= 2) {
					console.log('@@@',222);
					this.selected = []; //取消  
					this.selectedTwo.forEach((it, ind) => {
						this.$set(this.selectedTwo[ind], 'value', '')
					})
					value1 = "";
					value2 = "";
					// this.$set(this.selectedTwo[index],'value','')
				} else {
					console.log('@@@',item);
					this.selected.push(item) //选中添加到数组里

					if (this.selected.length > 2) {
						this.selected.pop() 
					}
					console.log(this.selectedTwo);
					this.$set(this.selectedTwo[index], 'value', this.selected[0].value)
					value1 = this.selected[0].value
					if (this.selected.length > 1) {
						value2 = this.selected[1].value
					}
					if (this.selected.length >= 2) {
						let start = this.lists.findIndex(it => it.value == this.selected[0].value)
						let end = this.lists.findIndex(it => it.value == this.selected[1].value)
						this.lists.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo[index], 'value', it.value)
							}
						})

						starts = start
						ends = end
					}


				}
				this.value1 = value1
				this.value2 = value2
			},

			btn2(item, index) {
				let value3 = "";
				let value4 = "";
				if (index >= starts1 && index <= ends1 && this.selected2.length >= 2) {
					this.selected2 = []; //取消
					this.selectedTwo2.forEach((it, ind) => {
						this.$set(this.selectedTwo2[ind], 'valuea', '')
					})
					value3 = "";
					value4 = "";
					
					// this.$set(this.selectedTwo[index],'value','')

				} else {

					this.selected2.push(item) //选中添加到数组里
					console.log(this.selected2)
					if (this.selected2.length > 2) {
						this.selected2.pop()
					}
					this.$set(this.selectedTwo2[index], 'valuea', this.selected2[0].valuea)
					value3 = this.selected2[0].valuea
					if (this.selected2.length > 1) {
						value4 = this.selected2[1].valuea
					}
					if (this.selected2.length >= 2) {
						let start = this.lists1.findIndex(it => it.valuea == this.selected2[0].valuea)
						let end = this.lists1.findIndex(it => it.valuea == this.selected2[1].valuea)
						this.lists1.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo2[index], 'valuea', it.valuea)
							}
						})

						starts1 = start
						ends1 = end
					}


				}
				this.value3 = value3
				this.value4 = value4
				console.log('value3', this.value3, 'value4', this.value4, '----')
				// this.dateFormat()
			},
			btn3(item, index) {
				let value5 = "";
				let value6 = "";
				if (index >= starts2 && index <= ends2 && this.selected3.length >= 2) {
					this.selected3 = []; //取消
					this.selectedTwo3.forEach((it, ind) => {
						this.$set(this.selectedTwo3[ind], 'valueb', '')
					})
					value5 = "";
					value6 = "";
					// this.$set(this.selectedTwo[index],'value','')

				} else {

					this.selected3.push(item) //选中添加到数组里

					if (this.selected3.length > 2) {
						this.selected3.pop()
					}
					this.$set(this.selectedTwo3[index], 'valueb', this.selected3[0].valueb)
					value5 = this.selected3[0].valueb
					if (this.selected3.length > 1) {
						value6 = this.selected3[1].valueb
					}
					if (this.selected3.length >= 2) {
						let start = this.lists2.findIndex(it => it.valueb == this.selected3[0].valueb)
						let end = this.lists2.findIndex(it => it.valueb == this.selected3[1].valueb)
						this.lists2.forEach((it, index) => {
							if (index > start && index <= end) {
								this.$set(this.selectedTwo3[index], 'valueb', it.valueb)
							}
						})

						starts2 = start
						ends2 = end
					}


				}
				this.value5 = value5
				this.value6 = value6
				console.log('value5', this.value5, 'value6', this.value6, '----')
			},
			// 确定
			async confirms() {
				if (this.sj == this.sj1 && this.sj.length == 14) {
					uni.showToast({
						title: '请选择时间',
						icon: 'none'
					})
					return
				}
				let params = {
					longitude: this.longitude,
					latitude: this.latitude,
					expectEndTime: this.sj1,
					expectStartTime: this.sj,
					tenantId: 1
				}
				console.log(this.sj)
				let res = await homeServices.confirms(params)
				console.log(res, 'qqqqqqqqqqqq')
				let arr = res.msg
				if (res.status == 200) {
					let nums = 1
					uni.$emit('updateNum', res.data)

					console.log(res.data);

					uni.switchTab({
						url: `/pages/index/index`
					})
				} else {
					uni.showToast({
						title: arr,
						icon: 'none',
						duration: 3000,
					});
				}

			},
			async confirms2() {
				if(this.value3!=''&&this.value4!='' ){
					var params = {
						expectEndTime: this.mt2,
						expectStartTime: this.mt1,
						longitude: this.longitude,
						latitude: this.latitude,
					}
				}else{
					var params = {
						expectEndTime: '1970-01-01 01:01:01',
						expectStartTime: this.shijian5 +' 00:01:01',
						longitude: this.longitude,
						latitude: this.latitude,
					}
				}
				
				let res = await homeServices.confirms(params)
				console.log(res)
				uni.switchTab({
					url: `/pages/index/index`
				})
				console.log(res)
			},
			async confirms3() {
				if(this.value5!=''&&this.value6!='' ){
					var params = {
						expectEndTime: this.houtian2,
						expectStartTime: this.houtian1,
						longitude: this.longitude,
						latitude: this.latitude
					}
				}else{
					var params = {
						expectEndTime: '1970-01-01 01:01:01',
						expectStartTime: this.shijian6 +' 00:01:01',
						longitude: this.longitude,
						latitude: this.latitude,
					}
				}
				
				let res = await homeServices.confirms(params)
				uni.switchTab({
					url: `/pages/index/index`
				})
				console.log(res)
			},
			async offline() {

				let res = await homeServices.offline()
				console.log(res)
				if (res.status == 200) {
					uni.switchTab({
						url: `/pages/index/index`
					})
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
				}


			}
		},

		onShow() {
			this.today(1)
			let _this = this;
			// setInterval(function() {
			_this.date = Date.parse(new Date());
			// }, 1000);
		},
		onLoad(options) {
			this.homeluobo()
			this.selectedTwo = JSON.parse(JSON.stringify(this.lists))
			this.selectedTwo.forEach((item, index) => {
				this.$set(this.selectedTwo[index], 'value', '')
			})
			this.selectedTwo2 = JSON.parse(JSON.stringify(this.lists1))
			this.selectedTwo2.forEach((item, index) => {
				this.$set(this.selectedTwo2[index], 'valuea', '')
			})
			this.selectedTwo3 = JSON.parse(JSON.stringify(this.lists2))
			this.selectedTwo3.forEach((item, index) => {
				this.$set(this.selectedTwo3[index], 'valueb', '')
			})
			console.log(this.selectedTwo)
			this.longitude = options.longitude
			this.latitude = options.latitude
			console.log(this.longitude, this.latitude)
			// let _this = this;
			// // setInterval(function() {
			// _this.date = Date.parse(new Date());
			// // }, 1000);
			this.getCurrentTime()
			

		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/sass/onlinetime.scss'
</style>
